<?php #//AJAX PHP PENNY AUCTION v.1.1

#///////////////////////////////////////////////////////////
#//  COPYRIGHT 2009 Aaron Helmlinger ALL RIGHTS RESERVED  //
#///////////////////////////////////////////////////////////










  $title_for_header = $_GET['title'];

include './includes/config.inc.php';
include $include_path.'auction_types.inc.php';
include $include_path.'dates.inc.php';
include $include_path."membertypes.inc.php";
 include './includes/general_info.inc.php';

                           $query_settings = "select * from PHPAUCTIONXL_version_2_0 where id='1'";
                             $query_settings2 =  mysql_query ($query_settings);
                                $reserve1 = mysql_result($query_settings2,0,"hide_reserve");
                               $savings1  = mysql_result($query_settings2,0,"hide_savings");
                               $autobidder1 = mysql_result($query_settings2,0,"hide_autobidder");
                                     $page_counter1 = mysql_result($query_settings2,0,"hide_pagecounter");
                               

   $query = mysql_fetch_array(mysql_query("SELECT * FROM PHPAUCTIONXL_version_1_3 WHERE id='1'"));
  
   $admin_daily_win_limits = $query['daily_win_limits'];
 $admin_weekly_win_limits = $query['weekly_win_limits'];
   $admin_monthly_win_limits = $query['monthly_win_limits'];
         $average_bid_price1 = $query['average_bid_price'];
        $pause_auctions_start1 = $query['pause_auctions_start'];
        $pause_auctions_end1 = $query['pause_auctions_end'];
         $tax_rate2 = $query['tax_rate_percentage'];
        $average_bid_price2 = $query['average_bid_price'];
         
         
         
                   $query = mysql_fetch_array(mysql_query("SELECT * FROM PHPAUCTIONXL_version_2_1 WHERE id='1'"));
  
   $admin_elite_auction_limit = $query['elite_auction_limit'];
   $admin_force_paid_limit = $query['force_payment_limit']; 
         
         
                          $queryunpaid = "select * from PHPAUCTIONXL_auctions
         WHERE current_high_bidder='$_SESSION[PHPAUCTION_LOGGED_IN_USERNAME]' AND 
         paid=0 AND closed=1";
$resultunpaid = mysql_query($queryunpaid);
$user_unpaid = mysql_num_rows($resultunpaid);


if ( $user_unpaid > $admin_force_paid_limit ) {

$unpaid_limits = 1;
    $win_limits = 1;
  
} 
                 

 
                 
 
 
 
 
 
 
 
 
 
   
         
         $query = "select timebefore,extend from PHPAUCTIONXL_auctionextension
         WHERE timebefore>'0'";
$result333 = mysql_query($query);
$num_auction = mysql_num_rows($result333);

 $i = 0;
while($i < $num_auction) {

  $sitewide_auto_activation 	= mysql_result($result333,$i,"timebefore");
  $sitewide_auto_extend 	= mysql_result($result333,$i,"extend");
$i++;
}

   
   $auto_extend_activated = $sitewide_auto_activation;
   $auto_extend_incremented = $sitewide_auto_extend;
   
// Create DATE & TIME

$TIME = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m"), date("d"),date("Y"));

$NOW = date("YmdHis",$TIME);






$jsenddate .= substr ($NOW, 4, 2);
$jsenddate .= "/";
$jsenddate .= substr ($NOW, 6, 2);
$jsenddate .= "/";
$jsenddate .= substr ($NOW, 0, 4);
$jsenddate .= " ";
/*
if (substr ($NOW, 8, 2) != 0 ) {
if (substr ($NOW, 8, 2) > 12) {
if ((substr ($NOW, 8, 2)-12) < 10) {


$jsenddate .= 0;
         }
            }
            }
            */
            
if (substr ($NOW, 8, 2) > 12) {
$jsenddate .= substr ($NOW, 8, 2)-12;
$jsampm = "PM";
}
if (substr ($NOW, 8, 2) != 00){
if (substr ($NOW, 8, 2) < 12) {
$jsenddate .= substr ($NOW, 8, 2);
$jsampm = "AM";
}}
if (substr ($NOW, 8, 2) == 12) {
$jsenddate .= substr ($NOW, 8, 2);
$jsampm = "PM";
}
if (substr ($NOW, 8, 2) == 00) {
$jsenddate .= 12;
$jsampm = "AM";
}


$jsenddate .= ":";
$jsenddate .= substr ($NOW, 10, 2);
$jsenddate .= ":";
$jsenddate .= substr ($NOW, 12, 2);
$jsenddate .= " ";
$jsenddate .= $jsampm;

$NOW2 = $jsenddate;


















#// Get parameters from the URL
$params = getUrlParams("=");
if(empty($_GET['id']))
    $_GET['id'] = $params['id'];
else
    $params['id'] = $_GET['id'];
$id = $params['id'];

$_SESSION["REDIRECT_AFTER_LOGIN"] = "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];

foreach($membertypes as $idm => $memtypearr) {
    $memtypesarr[$memtypearr['feedbacks']]=$memtypearr;
}
ksort($memtypesarr,SORT_NUMERIC);
$BIDFILE = $SETTINGS['siteurl']."bid.php";

if (!isset($_POST['id']) && !isset($_GET['id']) && isset($_SESSION["CURRENT_ITEM"])) {
    $id = $_SESSION["CURRENT_ITEM"];
}  elseif (isset($_REQUEST['id'])) {
    $_SESSION["CURRENT_ITEM"]=$_REQUEST['id'];
} else {
    // error message
    include "header.php";
    print "<table WIDTH=100% border=0 CELLPADDING=5>
               <tr><td align=\"center\" class=errfont>".$ERR_605."</td></tr>
              </table>";
    include "footer.php";
    exit;
}
// now check if requested auction exists and is/isn't closed
$AuctionIsClosed = false;
$query = "SELECT * FROM PHPAUCTIONXL_auctions WHERE id=".$_SESSION["CURRENT_ITEM"]." and suspended=0";
$result = mysql_query ($query);
if ( mysql_num_rows($result ) == 0) {
    include "header.php";
    print "<table WIDTH=100% border=0 CELLPADDING=5>
                      <tr><td align=\"center\" class=errfont>".$ERR_122."</td></tr>
                      </table>";
    include "footer.php";
    exit;
}
$ITEM = mysql_fetch_array($result);
$closed = intval(mysql_result($result,0,"closed"));
$page_title = stripslashes($ITEM['title']);
if ($closed==1) $AuctionIsClosed=1;

if ( mysql_result($result,0,"suspended") == 1 ) {
  $closed_or_suspended = 1;
  $ERR_SUSPENDED = $ERR_123;
}

if ( $closed_or_suspended ) {
  include "header.php";
  print "<TABLE WIDTH=100% BORDER=0 CELLPADDING=5 BGCOLOR=#ffffff>
            <TR><TD><CENTER>".
              mysql_result($result,0,"title").
              "<br>$std_font $ERR_SUSPENDED 
              </FONT></CENTER></TD></TR>
            </TABLE>";
  include "footer.php";
  exit;
}

if($SETTINGS['adultonly']=='y' && !isset($_SESSION["PHPAUCTION_LOGGED_IN"]) && $ITEM['adultonly']=='y'){
    Header("Location: index.php");
    exit;
}

$query = "select * from PHPAUCTIONXL_bids where auction=".intval($id)." ORDER BY id DESC";
$result_numbids = mysql_query ($query);
if (!$result_numbids) {
    MySQLError($query);
    exit;
}
$num_bids = mysql_num_rows ($result_numbids);
if ($num_bids > 0 && !isset($_GET['history'])) {
    $TPL_BIDS_value = "<a href='".$SETTINGS[siteurl]."item.php?id=$id&history=view#history'>$MSG_105</a>";
} elseif (isset($_GET['history'])) {
    $TPL_BIDS_value = "<a href='".$SETTINGS[siteurl]."item.php?id=$id'>$MSG_507</a>";
}

/* get auction data  */
$query = "select * from PHPAUCTIONXL_auctions where id=".intval($id);
$result = mysql_query($query);
if ( !$result ) {
    MySQLError($query);
    exit;
}
$auction_id = intval($id);

$user           = stripslashes(mysql_result ( $result, 0, "user" ));
$title          = stripslashes(mysql_result ( $result, 0, "title" ));
$date           = mysql_result ( $result, 0, "starts" );
$item_description    = stripslashes(mysql_result ( $result, 0, "description" ));
$item_description = str_replace("&nbsp;", " ", $item_description);
$item_description = html_entity_decode($item_description);
//$item_description = htmlspecialchars_decode($item_description); 

$pict_url       = mysql_result ( $result, 0, "pict_url" );
$category       = mysql_result ( $result, 0, "category" );
$minimum_bid    = mysql_result ( $result, 0, "minimum_bid" );
$reserve_price  = mysql_result ( $result, 0, "reserve_price" );
$buy_now        = mysql_result ( $result, 0, "buy_now" );
$buy_now_price  = mysql_result ( $result, 0, "buy_now" );
$auction_type   = mysql_result ( $result, 0, "auction_type" );
$location       = mysql_result ( $result, 0, "location" );
$item_custom_increment = mysql_result ( $result, 0, "increment" );
$location_zip   = mysql_result ( $result, 0, "location_zip" );
$shipping       = mysql_result ( $result, 0, "shipping" );
$item_shipping_terms = mysql_result ( $result, 0, "shipping_terms" );
$item_payments_accepted = mysql_result ( $result, 0, "payment" );
$international  = mysql_result ( $result, 0, "international" );
$ends = mysql_result ( $result, 0, "ends" );
$item_current_high_bidder    = mysql_result ( $result, 0, "current_high_bidder" );
$item_return_policy = mysql_result ( $result, 0, "return_policy" );
$item_extend_activated = mysql_result ( $result, 0, "ae_activation" );
$item_extend_increment = mysql_result ( $result, 0, "ae_increment" );
$allow_autobidder2 = mysql_result ( $result, 0, "allow_autobidder" );
$closed = mysql_result ( $result, 0, "closed" );
$bid_credits_reqd1 = mysql_result ( $result, 0, "bid_credits_reqd" );
$notimer = mysql_result ( $result, 0, "notimer" );
$seat_qty = mysql_result ( $result, 0, "seat_qty" );
$hard_reset = mysql_result ( $result, 0, "hard_reset" );          
$lockout = mysql_result ( $result, 0, "lockout" );
$auctiontype2 = mysql_result ( $result, 0, "auction_type2" );                   
 
 
         $query = mysql_fetch_array(mysql_query("SELECT * FROM PHPAUCTIONXL_version_1_4 WHERE id='1'"));
  
   $admin_beginner_auction_limit = $query['beginner_auction_limit'];
   
              $id2 = $_SESSION["PHPAUCTION_LOGGED_IN"];
              
             $query = mysql_fetch_array(mysql_query("SELECT * FROM PHPAUCTIONXL_users WHERE id='$id2'"));
  
   $daily_wins_query = $query['daily_wins'];
   
        
          if ( $auctiontype2 == "beginner" ) {
         if ( $daily_wins_query > $admin_beginner_auction_limit ) {

$beginner_limits = 1;
$win_limits = 1;
  
} 
   }
  
       
         if ( $auctiontype2 == "elite" ) {
           if ( $daily_wins_query < $admin_elite_auction_limit ) {

$elite_limits = 1;
$win_limits = 1;

  }
}           
   
 
  if ( $seat_qty > 0 ) {
  
$queryseats = "select * from PHPAUCTIONXL_auction_seats
         WHERE auctionid=$id AND userid=$id2";
$resultseats = mysql_query($queryseats);
$num_auctionseats = mysql_num_rows($resultseats);   

       
           if ( $num_auctionseats2 >= $seat_qty ){
$seat_limits = 1;
          $win_limits = 1;
  
    } 
 }
   
    

    if ( $hard_reset == 0 ) {
    
    
  $hard_reset1 = $ITEM_PAGE_TIME_EXT_TYPE_ADDED;  
    
    }

              if ( $hard_reset == 1 ) {
    
    
  $hard_reset1 = $ITEM_PAGE_TIME_EXT_TYPE_RESET;  
    
    }


                                   
 
    if ( $item_extend_activated > 0 ) {
$auto_extend_activated = $item_extend_activated;
                                    }
                                    
                                    
          if ( $item_extend_increment > 0 ) {  
   $auto_extend_incremented = $item_extend_increment;
                              }  
                              
                              
                              
 
$item_current_bid    = mysql_result ( $result, 0, "current_bid" );                             
$item_retail_price    = mysql_result ( $result, 0, "retail" );
$item_shipping_fee   = mysql_result ( $result, 0, "shipping_fee" );

// Calculate Savings / Buy Now

              $savings_buynow_user = $_SESSION["PHPAUCTION_LOGGED_IN"];
              
                 
             if($savings_buynow_user) {
  
   $query_settings = "select shipping_fee,retail,current_bid,bid_credits_reqd from PHPAUCTIONXL_auctions where id='$auction_id'";
                             $query_settings2 =  mysql_query ($query_settings);
                                $shipping_fee2 = mysql_result($query_settings2,0,"shipping_fee");
                                 $retail2 = mysql_result($query_settings2,0,"retail");
                                 $current_bid2 = mysql_result($query_settings2,0,"current_bid"); 
                                 $bid_credits_reqd = mysql_result($query_settings2,0,"bid_credits_reqd");  
    
    
    
      $query34543 = "select * from PHPAUCTIONXL_bids WHERE bidder='$savings_buynow_user' AND auction='$auction_id'";
$result34543 = mysql_query($query34543);
if($result34543) {
$number_of_bids = mysql_num_rows($result34543);
   }
   
if(empty($result34543)) {
$number_of_bids = 0;
   }   

}    
         


if ( empty($average_bid_price2)) {
   $number_of_bids_total = 0;
   }
 if (!empty($average_bid_price2)) {     
$number_of_bids_total = $number_of_bids * $average_bid_price2;
$number_of_bids_total = $number_of_bids_total2 * $bid_credits_reqd;
  }
  
$total_before_taxes = $item_shipping_fee + $number_of_bids_total + $item_current_bid;
      
 if ( $tax_rate2 == 0) {     
$tax_total = 0;
}
  if ( $tax_rate2 > 0) {     
$tax_total = $total_before_taxes * $tax_rate2;
}  
   
$taxes_shipping_total = $tax_total + $item_shipping_fee;

$savings_total = $item_retail_price - $number_of_bids_total - $taxes_shipping_total - $item_current_bid;


  if ( $item_retail_price > 0 ) {
$savings_percentage = $savings_total / $item_retail_price;
     }
     if( $item_retail_price == 0 ) {
$savings_percentage = 0;
     }

$savings_percentage2 = round($savings_percentage * 100);

         $jsenddate = "|";
           $jsenddate .= "|";
     $jsenddate .= $currency_symbol;
     $jsenddate .= print_money_nosymbol($current_bid2);
    $jsenddate .= "|"; 
    $jsenddate .= "- Bids Credits Used x ";
    $jsenddate .= $currency_symbol;
    $jsenddate .= print_money_nosymbol($average_bid_price2);
    $jsenddate .= " Each:";
    $jsenddate .= "|";
    $jsenddate .= $currency_symbol;
    $jsenddate .= print_money_nosymbol($number_of_bids_total);
    $jsenddate .= "|";
    $jsenddate .= $currency_symbol;
    $jsenddate .= print_money_nosymbol($taxes_shipping_total);
    $jsenddate .= "|";
    $jsenddate .= $savings_percentage2;
    $jsenddate .= "% or ";
    $jsenddate .= $currency_symbol;
    $jsenddate .= print_money_nosymbol($savings_total);
    $jsenddate .= "|"; 
    $jsenddate .= "- Bids Credits Used x ";
    $jsenddate .= $currency_symbol;
    $jsenddate .= print_money_nosymbol($average_bid_price2);
    $jsenddate .= " Each:";
    $jsenddate .= "|";
    $jsenddate .= $currency_symbol;
    $jsenddate .= print_money_nosymbol($number_of_bids_total);
    $jsenddate .= "|";
  
$total_before_taxes_buynow = $item_shipping_fee + $number_of_bids_total;
  
if (!empty($tax_rate2)) {     
$tax_total_buynow = $total_before_taxes_buynow * $tax_rate2;
}  
            $jsenddate .= $currency_symbol;
    $jsenddate .= print_money_nosymbol($tax_total_buynow);
    $jsenddate .= "|";
      
$buynow_total = $item_retail_price - $number_of_bids_total + $tax_total_buynow;

$jsenddate .= $currency_symbol;
$jsenddate .= print_money_nosymbol($buynow_total);
$jsenddate .= "|";













$pausestarthour = $pause_auctions_start1;  // Set To 24 For Always Running
$pauseendhour = $pause_auctions_end1;   // Set To 24 For Always Running




$currenthour = substr($NOW, 8, 2);

$paused1 = 0;

if ( $pausestarthour <= $currenthour && $pauseendhour >= $currenthour ) {


$paused1 = 1;
    

}

if ( $pausestarthour == 0 && $pauseendhour == 0 ) {


$paused1 = 0;
    

}



if ( $date > $NOW ) {

$not_open = 1;

}


  
if ( $date < $NOW ) {

// Create END DATE & TIME

$jsenddate2 .= substr ($ends, 4, 2);
$jsenddate2 .= "/";
$jsenddate2 .= substr ($ends, 6, 2);
$jsenddate2 .= "/";
$jsenddate2 .= substr ($ends, 0, 4);
$jsenddate2 .= " ";

if (substr ($ends, 8, 2) > 12) {
$jsenddate2 .= substr ($ends, 8, 2)-12;
$jsampm = "PM";
}
if (substr ($ends, 8, 2) != 0) {
if (substr ($ends, 8, 2) < 12) {
$jsenddate2 .= substr ($ends, 8, 2);
$jsampm = "AM";
}
}
if (substr ($ends, 8, 2) == 12) {
$jsenddate2 .= substr ($ends, 8, 2);
$jsampm = "PM";
}
if (substr ($ends, 8, 2) == 0) {
$jsenddate2 .= substr ($ends, 8, 2);
$jsampm = "AM";
}
$jsenddate2 .= ":";
$jsenddate2 .= substr ($ends, 10, 2);
$jsenddate2 .= ":";
$jsenddate2 .= substr ($ends, 12, 2);
$jsenddate2 .= " ";
$jsenddate2 .= $jsampm;


$ENDS2 = $jsenddate2;

}


// Create START DATE & TIME

if ( $date > $NOW ) {

$jsenddate22 .= substr ($date, 4, 2);
$jsenddate22 .= "/";
$jsenddate22 .= substr ($date, 6, 2);
$jsenddate22 .= "/";
$jsenddate22 .= substr ($date, 0, 4);
$jsenddate22 .= " ";

if (substr ($date, 8, 2) > 12) {
$jsenddate22 .= substr ($date, 8, 2)-12;
$jsampm = "PM";
}
if (substr ($date, 8, 2) != 0) {
if (substr ($date, 8, 2) < 12) {
$jsenddate22 .= substr ($date, 8, 2);
$jsampm = "AM";
}
}
if (substr ($date, 8, 2) == 12) {
$jsenddate22 .= substr ($date, 8, 2);
$jsampm = "PM";
}
if (substr ($date, 8, 2) == 0) {
$jsenddate22 .= substr ($date, 8, 2);
$jsampm = "AM";
}
$jsenddate22 .= ":";
$jsenddate22 .= substr ($date, 10, 2);
$jsenddate22 .= ":";
$jsenddate22 .= substr ($date, 12, 2);
$jsenddate22 .= " ";
$jsenddate22 .= $jsampm;


$STARTS2 = $jsenddate22;


}


$phu = intval(mysql_result( $result,0,"photo_uploaded") &&($pict_url!=''));
$atype = intval(mysql_result($result,0,"auction_type"));
$iquantity = mysql_result ($result,0,"quantity");
$nowt = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m"), date("d"),date("Y"));
$difference = mktime(substr ($ends, 8, 2),
substr ($ends, 10, 2),
substr ($ends, 12, 2),
substr ($ends, 4, 2),
substr ($ends, 6, 2),
substr ($ends, 0, 4))- $nowt;
$_SESSION['CURRENTAUCTIONUSER'] = $user;
$_SESSION['CURRENTAUCTIONTITLE'] = $title;
#// Does the seller have a About me page
if($SETTINGS['aboutme'] == 'y') {
    $query = "SELECT user FROM PHPAUCTIONXL_aboutmeusers WHERE user=".intval($user);
    $res_ab = @mysql_query($query);
    if(!$res_ab) {
        MySQLError($query);
        exit;
    } elseif(mysql_num_rows($res_ab) > 0) {
        $SELLERHASABOUTME = $user;
    } else {
        $SELLERHASABOUTME = FALSE;
    }
}

require("header.php");

$TPL_auction_type = $auction_types[$atype];
/*    if ($atype==2)
{ */
$TPL_auction_quantity = $iquantity;
$TPL_qty = "<SELECT NAME=qty SIZE=1>";
for ($i=1; $i<=$iquantity; $i++) {
    $TPL_qty .= "<OPTION VALUE=$i ";
    if ($i==1){$TPL_qty .= "SELECTED";}
    $TPL_qty .=  ">".$i." </OPTION>";
}
$TPL_qty .= "</SELECT>";
/*    } */

#// Added by Gian dec. 12 2002
#//
#// Auction view counter
$query = "SELECT counter as counter from PHPAUCTIONXL_auccounter where auction_id=".intval($id);
$rcount=@mysql_query($query);
if(!$rcount) {
    MySQLError($query);
    exit;
}
if(mysql_num_rows($rcount)==0) {
    mysql_query("INSERT INTO PHPAUCTIONXL_auccounter VALUES (".intval($id).",1)");
    $TPL_nr=1;
} else {
    $TPL_nr=mysql_result($rcount,0,"counter");
    mysql_query("UPDATE PHPAUCTIONXL_auccounter set counter='".intval($TPL_nr+1)."' where auction_id=".intval($id));
}
//categories list
$c_name[] = array(); $c_id[] = array();
$TPL_cat_value = "";

$query = "SELECT cat_id,parent_id,cat_name FROM PHPAUCTIONXL_categories WHERE cat_id=".intval($category);
$result = mysql_query($query);
if ( !$result ) {
    MySQLError($query);
    exit;
}
$result     = mysql_fetch_array ( $result );
$parent_id  = $result['parent_id'];
$cat_id     = $categories;

$j = $category;
$i = 0;
do {
    $query = "SELECT cat_id,parent_id,cat_name FROM PHPAUCTIONXL_categories WHERE cat_id='$j'";
    $result = mysql_query($query);
    if ( !$result )    {
        MySQLError($query);
        exit;
    }
    $result = mysql_fetch_array ( $result );
    if ( $result ) {
        $parent_id  = $result['parent_id'];
        #//  Select the translated category name
        $cat_name = @mysql_result(mysql_query("SELECT cat_name FROM PHPAUCTIONXL_cats_translated WHERE cat_id=".$result['cat_id']." AND lang='".$language."'"),0,"cat_name");
        
        $c_name[$i] = $cat_name;
        $c_id[$i]   = $result['cat_id'];
        $i++;
        $j = $parent_id;
    } else {
        // error message
        print "<p class=errfont>".$ERR_620."</p>";
        include "footer.php";
        exit;
    }
} while ( $parent_id != 0 );

for ($j=$i-1; $j>=0; $j--) {
    if ( $j == 0) {
        $TPL_cat_value .= "<a href='".$SETTINGS['siteurl']."browse.php?id=".$c_id[$j]."'>".$c_name[$j]."</a>";
    } else {
        $TPL_cat_value .= "<a href='".$SETTINGS['siteurl']."browse.php?id=".$c_id[$j]."'>".$c_name[$j]."</a> / ";
    }
}


#// Pictures Gellery
$K = 0;
if(file_exists($uploaded_path.$id)) {
    $dir = @opendir($uploaded_path.$id);
    if($dir) {
        while($file = @readdir($dir)) {
            if($file != "." && $file != "..") {
                $UPLOADED_PICTURES[$K] = $file;
                $K++;
            }
        }
        @closedir($dir);
    }
    $GALLERY_DIR = $id;
    
    $TPL_show_gallery = "";
    if(is_array($UPLOADED_PICTURES)) {
        $TPL_show_gallery .= "";
        while(list($k,$v) = each($UPLOADED_PICTURES)) {
            $TMP = @GetImageSize($uploaded_path.$GALLERY_DIR."/".$v);
            if ($TMP[2]>=1 && $TMP[2]<=3) {
                $WIDTH = $TMP[0];
                $HEIGHT = $TMP[1];
                $TPL_show_gallery .= " 
                
                
                
                                       
<div class=\"PICTURE_GALLERY_SMALL_1\">
<div class=\"PICTURE_GALLERY_SMALL_2\">
<img src=".$SETTINGS['siteurl']."getthumb.php?w=".($SETTINGS['thumb_show']-25)."&fromfile=$uploaded_path"."$GALLERY_DIR/$v border=0 onmouseover=\"button('placeholder','".$SETTINGS['siteurl']."getthumb.php?w=".($SETTINGS['thumb_show']+160)."&fromfile=$uploaded_path"."$GALLERY_DIR/$v')\">\r
</div>
</div>";
                 
            }
        }
    }
    if(count($UPLOADED_PICTURES) > 0) {
        $TPL_gallery = "<a href='#gallery'><img src=".$SETTINGS['siteurl']."images/gallery.gif border=0 alt='gallery' /></a>&nbsp;<a href='#gallery'>$MSG_694</a>";
    } else {
        $TPL_gallery = "";
    }
}

//-- Get RESERVE PRICE information
if ($reserve_price > 0) {
    $TPL_reserve_price = "$MSG_030 ";
    
    //-- Has someone reached the reserve price?
    if($current_bid < $reserve_price) {
        $TPL_reserve_price .= " ($MSG_514)";
    } else {
        $TPL_reserve_price .= " ($MSG_515) ";
    }
} else {
    $TPL_reserve_price = "$MSG_029";
}


//-- BUY NOW ++++++++++++++++++++++++++++++
$query= "select max(bid) AS maxbid FROM PHPAUCTIONXL_proxybid WHERE itemid=".intval($id);
$res = @mysql_query($query);
$maxbid=mysql_result ( $res, 0, "maxbid" );

if ($buy_now_price > 0 && ($num_bids==0 || ($reserve_price >0 && $current_bid < $reserve_price)) && !($maxbid>0 && $maxbid >= $reserve_price) && $difference > 0) {
    $buy_now_price = print_money($buy_now_price);
    $TPL_buy_now_price = "$buy_now_price  <a href='".$SETTINGS['siteurl']."buy_now.php?id=$id'><img border='0' align='absbottom' alt='$MSG_496' src='".$SETTINGS['siteurl']."images/buy_it_now.gif' /></a>";
} else {
    $TPL_buy_now_price = $MSG_029;
}

$TPL_id_value           = $id;
$TPL_title_value        = $title;
$description  = $description;
//print $phu;

/* get user's nick */
$query      = "SELECT id,nick,trusted,reg_date FROM PHPAUCTIONXL_users WHERE id=".intval($user);

$result_usr = mysql_query ( $query );
if ( !$result_usr ) {
    print $ERR_001;
    exit;
}
$user_nick    = mysql_result ( $result_usr, 0, "nick");
$user_id    = mysql_result ( $result_usr, 0, "id");
$user_trusted    = mysql_result ( $result_usr, 0, "trusted");
$tmp_reg_date=mysql_result ( $result_usr, 0, "reg_date");
if (mysql_get_client_info() < 4.1 || !strstr($tmp_reg_date,"-")){
  $day = substr($tmp_reg_date,6,2);
  $month = substr($tmp_reg_date,4,2);
  $year = substr($tmp_reg_date,0,4);
  $hours = substr($tmp_reg_date,8,2);
  $minutes = substr($tmp_reg_date,10,2);
} else {
  $day = substr($tmp_reg_date,8,2);
  $month = substr($tmp_reg_date,5,2);
  $year = substr($tmp_reg_date,0,4);
  $hours = substr($tmp_reg_date,11,2);
  $minutes = substr($tmp_reg_date,14,2);
}
$user_reg_date = ArrangeDateNoCorrection($day,$month,$year,$hours,$minutes);

$TPL_user_nick_value = $user_nick;
if($user_trusted == 'y'){
    $TPL_seller_trusted = "&nbsp;<img src=\"".$SETTINGS['siteurl']."images/trusted.gif\" alt=\"trusted\"/>";
}else{
    $TPL_seller_trusted = "";
}
$TPL_user_reg_date = $MSG_5508.$user_reg_date;

/* get bids for current item */
$query          = "select max(bid) AS maxbid, bidder FROM PHPAUCTIONXL_bids WHERE auction=".intval($id)." GROUP BY id ORDER BY id DESC";
$result_bids = mysql_query($query);
if ( !$result_bids ) {
    print $ERR_001;
    exit;
}

if ( mysql_num_rows($result_bids ) > 0) {
    $high_bid       = mysql_result ( $result_bids, 0, "maxbid" );
    $high_bidder_id = mysql_result ( $result_bids, 0, "bidder" );

    #// Does the seller have a About me page
    if($SETTINGS['aboutme'] == 'y')    {
        $query = "SELECT user FROM PHPAUCTIONXL_aboutmeusers WHERE user=".intval($high_bid);
        $res_ab = @mysql_query($query);
        if(!$res_ab) {
            MySQLError($query);
            exit;
        } elseif(mysql_num_rows($res_ab) > 0) {
            $BIDDERHASABOUTME = $high_bidder_id;
        } else {
            $BIDDERHASABOUTME = FALSE;
        }
    }
}

if ( !mysql_num_rows($result_bids) ) {
    $num_bids = 0;
    $high_bid = 0;
} else {
    /* Get number of bids  */
    $num_bids = mysql_num_rows ( $result_numbids );

    /* Get bidder nickname */
    $query         = "select id,nick,trusted from PHPAUCTIONXL_users where id=".intval($high_bidder_id);
    $result_bidder = mysql_query($query);
    if ( !$result_bidder ) {
        MySQLError($query);
        exit;
    }
    //$high_bidder_id   = mysql_result ( $result_bidder, 0, "id" );
    //$high_bidder_nick = mysql_result ( $result_bidder, 0, "nick" );
    //$high_bidder_trusted = mysql_result ( $result_bidder, 0, "trusted" );
   // if($high_bidder_trusted == 'y'){
        $TPL_bidder_trusted = "&nbsp;<img src=\"".$SETTINGS['siteurl']."images/trusted.gif\" alt=\"trusted\"/>";
    //}else{
      //  $TPL_bidder_trusted = "";
    //}

}

#// #####################################################################################################
#// If no bids placed, the current bid is the minimum bid

if($high_bid == 0) {
    $HIGH_BID = $minimum_bid;
} else {
    $HIGH_BID = $high_bid;
}

/* Get bid increment for current bid and calculate minimum bid */
$query = "SELECT increment FROM PHPAUCTIONXL_increments WHERE".
"((low<=$HIGH_BID AND high>=$HIGH_BID) OR".
"(low<$HIGH_BID AND high<$HIGH_BID)) ORDER BY increment DESC";

$result_incr = mysql_query  ( $query );
if(mysql_num_rows($result_incr) != 0) {
    $increment   = mysql_result ( $result_incr, 0, "increment" );
}

if($atype == 2) {
    $increment = 0;
}

if($customincrement > 0) {
    $increment   = $customincrement;
}

if ($high_bid == 0 || $atype ==2) {
    $next_bid = $minimum_bid;
} else {
    $next_bid = $high_bid + $increment;
}

$high_bid = $HIGH_BID;

if ( $pict_url ) {
    $TPL_pict_url_value  = "<a href='#image'><img src='".$SETTINGS['siteurl']."images/picture.gif' border=0 alt='image' /></a>&nbsp;"
    ."<a href='#image'>$MSG_108</a>"
    ."<img src='".$SETTINGS['siteurl']."images/transparent.gif' WIDTH=15 alt='' />";
}

/* Get current number of feedbacks */
$query          = "SELECT rated_user_id FROM PHPAUCTIONXL_feedbacks WHERE rated_user_id=".intval($user_id);
$result         = mysql_query   ( $query );
$num_feedbacks  = mysql_num_rows ( $result );
$num_feedbacks_not_same_rater  = mysql_num_rows ( $result );
$query          = " SELECT rated_user_id FROM PHPAUCTIONXL_feedbacks WHERE rated_user_id='$user_id'";
$result         = mysql_query   ( $query );

/* Get current total rate value for user */
$query         = "SELECT distinct count(*) total FROM PHPAUCTIONXL_feedbacks WHERE rated_user_id=".$user_id." AND rate<>0";

$result        = mysql_query  ( $query );
if($result && mysql_num_rows($result) > 0) {
    $total_rate    = mysql_result ( $result, 0, "total" );
}

/* Get positive and negative feedbacks for user Edgar 18/09/2005 */
$query         = "SELECT distinct count(*) negative FROM PHPAUCTIONXL_feedbacks WHERE rated_user_id='$user_id' and rate=-1";
$result        = mysql_query  ( $query );
if($result && mysql_num_rows($result) > 0) {
    $negative_feedbacks    = mysql_result ( $result, 0, "negative" );
}else $negative_feedbacks = 0;

$query         = "SELECT distinct count(*) positive FROM PHPAUCTIONXL_feedbacks WHERE rated_user_id='$user_id' and rate=1";
$result        = mysql_query  ( $query );
if($result && mysql_num_rows($result) > 0) {
    $positive_feedbacks    = mysql_result ( $result, 0, "positive" );
}else $negative_feedbacks = 0;

$TPL_vendetor_value = "<a href='".$SETTINGS['siteurl']."profile.php?user_id=$user_id&auction_id=$id'><b>".$TPL_user_nick_value."</b></a>";

$i=0;
foreach ($memtypesarr as $k=>$l) {
    if($k >= $total_rate || $i++==(count($memtypesarr)-1)) {
        $TPL_rate_radio="<img src=\"".$SETTINGS['siteurl']."images/icons/".$l['icon']."\" alt=\"".$l['icon']."\" />";
        break;
    }
}
$TPL_num_feedbacks="( <A HREF='".$SETTINGS['siteurl']."feedback.php?id=$user_id&faction=show'>$total_rate</A> )";

#// Positive and negative feedback
$TPL_percent_positive_feedbacks=$num_feedbacks > 0 ? "(".ceil($positive_feedbacks*100/$total_rate)."%)" : "0%";
$TPL_percent_negative_feedbacks=$negative_feedbacks > 0 ? "&nbsp;&nbsp;&nbsp;<b>$MSG_5507 (".ceil($negative_feedbacks*100/$total_rate)."%)</B><br>" : "";

$TPL_tot_feedbacks="<a href=".$SETTINGS['siteurl']."feedback.php?id=$user_id&faction=show>(".$num_feedbacks.")</a>";
/* High bidder  */
if ( $high_bidder_id ) {
    $TPL_hight_bidder_id  = "<tr><td WIDTH='30%'><b>"
    .$MSG_117.":</b></td><td>"
    ."<a href='".$SETTINGS['siteurl']."profile.php?user_id=$high_bidder_nick'>$high_bidder_nick</a>";

    /* Get current number of feedbacks */
    $query           = "select rated_user_id from PHPAUCTIONXL_feedbacks where rated_user_id=".intval($high_bidder_id);
    $result           = mysql_query ( $query );
    $num_feedbacks = mysql_num_rows($result);

    /* Get current total rate value for user */
    $query = "select rate_sum,nick,id from PHPAUCTIONXL_users where nick='".addslashes($high_bidder_nick)."'";
    $result = mysql_query($query);

  //  $total_rate = mysql_result($result,0,"rate_sum");
   // $nickname = mysql_result($result,0,"nick");
  //  $userid = mysql_result($result,0,"id");

    $i=0;
    foreach ($memtypesarr as $k=>$l) {
        if($k >= $total_rate || $i++==(count($memtypesarr)-1)) {
            $TPL_bidder_rate_radio="<img src=\"".$SETTINGS['siteurl']."images/icons/".$l['icon']."\" alt=/".$l['icon']."\" />";
            break;
        }
    }

    $TPL_hight_bidder_id ="<a href='".$SETTINGS['siteurl']."profile.php?user_id=$userid&auction_id=$id'><b>$high_bidder_nick</b></a>";
    $TPL_bidder_rate="<b>($total_rate)</b>";
    $TPL_bidder_feedbacks="<a href='".$SETTINGS['siteurl']."feedback.php?id=$userid&faction=show'>(".$num_feedbacks.")</a>";
}

if ($difference > 0) {
    $days_difference = floor($difference / 86400);
    $difference = $difference % 86400;
    $hours_difference = floor($difference / 3600);
    $difference = $difference % 3600;
    $minutes_difference = floor($difference / 60);
    $seconds_difference = $difference % 60;
    $TPL_difference_value = sprintf("%d%s %02dh:%02dm:%02ds",$days_difference,$MSG_126, $hours_difference,$minutes_difference,$seconds_difference);
} else {
    $TPL_difference_value = "<SPAN CLASS=errfont>$MSG_911</SPAN>";
}

$TPL_num_bids_value  = $num_bids;
$TPL_currency_value1 = "<a href=javascript:window_open('".$SETTINGS['siteurl']."converter.php?AMOUNT=$minimum_bid','incre',650,250,30,30)>".print_money($minimum_bid)."</a>";
$TPL_currency_value2 = "<a     href=javascript:window_open('".$SETTINGS['siteurl']."converter.php?AMOUNT=$high_bid','incre',650,250,30,30)>".print_money($high_bid)."</a>";
if($difference > 0) {
    $TPL_currency_value3 = "<a href=javascript:window_open('".$SETTINGS['siteurl']."converter.php?AMOUNT=$increment','incre',650,250,30,30)>".print_money($increment)."</a><br />";
    $TPL_currency_value4 = "<a href=javascript:window_open('".$SETTINGS['siteurl']."converter.php?AMOUNT=$next_bid','incre',650,250,30,30)>".print_money($next_bid)."</a>";
} else {
    $TPL_currency_value3 = "--<br />";
    $TPL_currency_value4 = "--";
}

/* Bidding table */
$TPL_next_bid_value   = $next_bid;
$TPL_user_id_value    = $user_id;
$TPL_title_value      = $title;
$TPL_category_value   = $category;
$TPL_id_value         = $id;

/* Description & Image table */
$TPL_description_value = nl2br($description);

// see if it's an uploaded picture
if ( $phu ) {
    $pict_url = $uploaded_path.$pict_url;
    $img=@getimagesize($pict_url);
    $sizedata=$img[3];
    $TPL_pict_url = "<img src='".$SETTINGS['siteurl']."$pict_url' $sizedata border=0 alt=\"\" />";
} elseif ($pict_url!='') {
    $TPL_pict_url = "<img src='$pict_url' border=0  alt=\"\" />";
} else {
    $TPL_pict_url = "<b>$MSG_114</b>";
}

/* Get location description */
include $include_path."countries.inc.php";
while ( list($key, $val) = each ($countries) ) {
    if ( $val == $location ) {
        $location_name = $val;
    }
}
$TPL_location_name_value = $location_name;
$TPL_location_zip_value  = "(".$location_zip.")";

if ( $shipping == '1' ) {
    $TPL_shipping_value = $MSG_038;
} else {
    $TPL_shipping_value = $MSG_032;
}
$TPL_shipping_terms = nl2br(stripslashes($shipping_terms));

if ( $international ) {
    $TPL_international_value = ", $MSG_033";
} else {
    $TPL_international_value = ", $MSG_043";
}

/* Get Payment methods */
$payment_methods = explode("\n",$payment);
$i = 0;
$c = count($payment_methods);
$began = false;
while ($i<$c) {
    if (strlen($payment_methods[$i])!=0 ) {
        if ($began) {
            $TPL_payment_value .= ", ";
        } else {
            $began = true;
        }
        $TPL_payment_value .= trim($payment_methods[$i]);
    }
    $i++;
}

$TPL_date_string1   = ArrangeDateNoCorrection(substr($date,6,2),substr($date,4,2),substr($date,0,4),substr($date,8,2),substr($date,10,2));
$TPL_date_string2   = ArrangeDateNoCorrection(substr($ends,6,2),substr($ends,4,2),substr($ends,0,4),substr($ends,8,2),substr($ends,10,2));




     
$item_auction_id = $TPL_id_value; 
$item_title = $TPL_title_value;
$item_number_of_bids_total = $TPL_num_bids_value;
$item_page_counter = $TPL_nr;
$item_photo_gallery = $TPL_show_gallery;
$item_category_heading = $TPL_cat_value;


$item_bid_history_link = "<A HREF=complete_history.php?id=";
$item_bid_history_link .= $TPL_id_value;
$item_bid_history_link .= " >".$VIEW_COMPLETE_HISTORY."</A>";

 
$tell_a_friend_link = "<a class=\"WATCHLINK\" HREF=";
$tell_a_friend_link .= $SETTINGS['siteurl'];
$tell_a_friend_link .= "friend.php?id=";
$tell_a_friend_link .= $TPL_id_value;
$tell_a_friend_link .= " >".$MSG_106."</A>";

$watch_item_link = "<a class=\"WATCHLINK\" HREF=";
$watch_item_link .= $SETTINGS['siteurl'];
$watch_item_link .= "item_watch.php?add=";
$watch_item_link .= $TPL_id_value;
$watch_item_link .= " >";  
$watch_item_link .= $MSG_472a;
$watch_item_link .= "</A>";


$item_photo_gallery_main_link = "<img NAME=\"placeholder\" SRC=".$SETTINGS['siteurl']."getthumb.php?w=";
$item_photo_gallery_main_link .= ($SETTINGS['thumb_show']+160);
$item_photo_gallery_main_link .= "&fromfile=".$pict_url." BORDER='0' ALIGN='center'>";





  $query_autobidder = "select activated from PHPAUCTIONXL_proxybid_settings where id=1";
                            $query_autobidder2 =  mysql_query ($query_autobidder);
                                 $num_auction2 = mysql_num_rows($query_autobidder2);
                                   $autobidder_activated = mysql_result($query_autobidder2,0,"activated");



                             if( $allow_autobidder2 == 1 ) { 

                                   

            // CREATE WIN LIMIT DATES

    $daylimitdatestart = substr ($NOW, 0, 8);
    $daylimitdatestart .= "000000";
         // echo $daylimitdatestart."<BR>";

    $TIMEdaylimitdateend = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m"), date("d")+1,date("Y"));

$NOWdaylimitdateend = date("YmdHis",$TIMEdaylimitdateend);

     $daylimitdateend = substr ($NOWdaylimitdateend, 0, 8);
    $daylimitdateend .= "000000";
          // echo $daylimitdateend."<BR>";
         $monthlylimitdatestart = substr ($NOW, 0, 6);
    $monthlylimitdatestart .= "01000000"; 
           // echo $monthlylimitdatestart."<BR>";
    
    $TIMEmonthlylimitdateend = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m")+1, date("d"),date("Y"));

$NOWmonthlylimitdateend = date("YmdHis",$TIMEmonthlylimitdateend);

     $monthlylimitdateend = substr ($NOWmonthlylimitdateend, 0, 6);
    $monthlylimitdateend .= "01000000";
                    // echo $monthlylimitdateend."<BR>";
    $jd=cal_to_jd(CAL_GREGORIAN,date("m"),date("d"),date("Y"));
$text_day = (jddayofweek($jd,1));

          //   echo $text_day;
    if ( $text_day == "Monday" ) {
        $day_correct_backwards = -1;
        $day_correct_forwards = 6;
    }  
    if ( $text_day == "Tuesday" ) {
        $day_correct_backwards = -2;
        $day_correct_forwards =5;
    }
    if ( $text_day == "Wednesday" ) {
        $day_correct_backwards = -3;
        $day_correct_forwards = 4;
    }
        if ( $text_day == "Thursday" ) {
        $day_correct_backwards = -4;
        $day_correct_forwards = 3;
    }
    if ( $text_day == "Friday" ) {
        $day_correct_backwards = -5;
        $day_correct_forwards =2;
    }
    if ( $text_day == "Saturday" ) {
        $day_correct_backwards = -6;
        $day_correct_forwards =1;
    }
    if ( $text_day == "Sunday" ) {
        $day_correct_backwards = 0;
        $day_correct_forwards = 7;
    }
    
        //  echo $day_correct_backwards;
      //  echo $day_correct_forwards;
$TIMEweeklylimitdatestart = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m"), date("d")+$day_correct_backwards,date("Y"));

$NOWweeklylimitdatestart = date("YmdHis",$TIMEweeklylimitdatestart);
    
        $weeklylimitdatestart = substr ($NOWweeklylimitdatestart, 0, 8);
    $weeklylimitdatestart .= "000000";

        // echo $weeklylimitdatestart."<BR>";
  
  $TIMEweeklylimitdateend = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m"), date("d")+$day_correct_forwards,date("Y"));

$NOWweeklylimitdateend = date("YmdHis",$TIMEweeklylimitdateend);
    
        $weeklylimitdateend = substr ($NOWweeklylimitdateend, 0, 8);
    $weeklylimitdateend .= "000000";
    //echo $weeklylimitdateend."<BR>";

// Query Auctions For Limits  
  
  
    $querydaily = "select * from PHPAUCTIONXL_auctions
         WHERE current_high_bidder='$_SESSION[PHPAUCTION_LOGGED_IN_USERNAME]' AND closed=1 AND
         ends > $daylimitdatestart AND
         ends < $daylimitdateend";
$resultdaily = mysql_query($querydaily);
$user_daily_wins = mysql_num_rows($resultdaily);

if ( $user_daily_wins >= $admin_daily_win_limits ) {

$win_limits = 1;

$win_limit_note = $MSG_WIN_LIMIT_DAILY_POPUP_NOTE;



     

    
  }         
    


       
          $queryweekly = "select * from PHPAUCTIONXL_auctions
         WHERE current_high_bidder='$_SESSION[PHPAUCTION_LOGGED_IN_USERNAME]' AND 
         closed=1 AND
         ends > $weeklylimitdatestart AND
         ends < $weeklylimitdateend";
$resultweekly = mysql_query($queryweekly);
$user_weekly_wins = mysql_num_rows($resultweekly);


if ( $user_weekly_wins >= $admin_weekly_win_limits ) {

$win_limits = 1;
 
  $win_limit_note = $MSG_WIN_LIMIT_WEEKLY_POPUP_NOTE;
  
}



     $querymonthly = "select * from PHPAUCTIONXL_auctions
         WHERE current_high_bidder='$_SESSION[PHPAUCTION_LOGGED_IN_USERNAME]' AND 
         closed=1 AND
         ends > $monthlylimitdatestart AND
         ends < $monthlylimitdateend";
$resultmonthly= mysql_query($querymonthly);
$user_monthly_wins = mysql_num_rows($resultmonthly);


    if ( $user_monthly_wins >= $admin_monthly_win_limits ) {

$win_limits = 1;
    
    $win_limit_note = $MSG_WIN_LIMIT_MONTHLY_POPUP_NOTE;
  
}
   }   

  /* $query_comparison = "select reserve_price,ends,id,title,current_high_bidder,current_bid,pict_url from PHPAUCTIONXL_auctions
         WHERE closed='1' AND ";
         $query_comparison .= "title='".$title."' order by id LIMIT 0,2";
$result_comparison = mysql_query($query_comparison);


$currentbidd = mysql_result($result_comparison,0,"current_bid");
  
    
                       $comparison = "<B>Recently Sold For: $";
                         $comparison .= $currentbidd;
                          $comparison .= "</b>";    */

                    
   if ( $autobidder_activated == 1 && $win_limits != 1 ) {



    $itemid =    $auction_id; 
   $update_autobidder = $_POST['update_autobidder'];



  if ( $update_autobidder == 1 ){

                   //echo "ergewrgwertwq34tq34twqergaerg";
                   
      $userid = $_POST['userid'];
   $itemid = $_POST['itemid'];
   $maxprice = $_POST['maxprice'];
   $maxbids = $_POST['maxbids'];
   $startprice = $_POST['startprice'];
   
                                //      echo $userid;
              //echo $itemid;
              //echo $maxprice;
              //echo $maxbids;
$num_auction = 0;

$query = "select * from PHPAUCTIONXL_proxybid
         WHERE itemid='$itemid' AND
         userid='$userid'";
$result = mysql_query($query);



$num_auction = mysql_num_rows($result);

                  $time_ends_seconds = substr ($ends, 0, 4); // Year
$time_ends_seconds .= "-";
$time_ends_seconds .= substr ($ends, 4, 2); // Month
$time_ends_seconds .= "-";
$time_ends_seconds .= substr ($ends, 6, 2); // Day
$time_ends_seconds .= " ";
$time_ends_seconds .= substr ($ends, 8, 2); // Hour
$time_ends_seconds .= ":";
$time_ends_seconds .= substr ($ends, 10, 2); // Minute
$time_ends_seconds .= ":";
$time_ends_seconds .= substr ($ends, 12, 2); // Second

$time_now_seconds = date("Y-m-d H:i:s",$TIME);
 

 
// convert to unix timestamps
$firstTime=strtotime($time_now_seconds);
$lastTime=strtotime($time_ends_seconds);

// perform subtraction to get the difference (in seconds) between times
$timeDiff=$lastTime-$firstTime;



$time_end_difference_in_seconds = $timeDiff;
$seconds_until_auction_ends = $time_end_difference_in_seconds;
       
 if ( $lockout == 1 ) {
 
 if ( $seconds_until_auction_ends < 180 ) {
 
       $lockout_limits = 1;
     $num_auction = 2;
       
 }
 
  }
      
 
 
 
 
 
         if ( $seconds_until_auction_ends > 8 ) {
         
if ( $num_auction == 1  ) {
$query2="UPDATE PHPAUCTIONXL_proxybid SET startbid='$startprice', bid='$maxprice', proxybidqty='$maxbids' WHERE userid='$userid' AND itemid='$itemid'";
  // echo $query2; 
mysql_query($query2);

}



 if ( empty($num_auction) ) {
 
 

 
    mysql_query("INSERT INTO PHPAUCTIONXL_proxybid (itemid, userid, bid, startbid, proxybidqty) VALUES ('$itemid', '$userid', '$maxprice', '$startprice', '$maxbids')");
                 
                  }
 
  // echo "234523523--------------------------";
}     

 }
 
 
 
 
 $userid = $_SESSION["PHPAUCTION_LOGGED_IN"];
               
               if ( $userid > 0) {

 $query_autobidder = "select * from PHPAUCTIONXL_proxybid where userid=$userid AND itemid=$auction_id";
                            $query_autobidder2 =  mysql_query ($query_autobidder);
                                 $num_auction2 = mysql_num_rows($query_autobidder2);
                               
                              if ( $num_auction2 == 1 ) { 
                                 
                                 
                                 
                                 
                                 
                                  //  echo "ITWORKSITWORKSITWORKSITWORKSITWORKSITWORKSITWORKSITWORKSITWORKS";
                                 
                                $userid = mysql_result($query_autobidder2,0,"userid");
                                $itemid = mysql_result($query_autobidder2,0,"itemid");
                                 $maxprice = mysql_result($query_autobidder2,0,"bid"); 
                                 $startprice = mysql_result($query_autobidder2,0,"startbid");
                                     $maxbids = mysql_result($query_autobidder2,0,"proxybidqty");
                                                 }
             // echo $userid;
              //echo $auction_id;
             // echo $maxprice;
             // echo $maxbids;


              }
                  }
                
              
include (phpa_include("template_item_php.html"));


if (isset($_GET['history']) && $num_bids > 0) {
    $i = 0;
    while ($bidrec=mysql_fetch_assoc($result_numbids)) {
      
        // --Get bidder's nickname
        $query = "select id,nick from PHPAUCTIONXL_users where id=".$bidrec['bidder'];
        $result_bidder = mysql_query($query);
        if (!$result) {
            MySQLError($query);
            exit;
        }
        $bidrec['bidder_name'] = mysql_result ($result_bidder, 0, "nick");

        // -- Format bid date
        $bidrec['bidwhen']=ArrangeDateNoCorrection(    substr($bidrec['bidwhen'], 6, 2),
        substr($bidrec['bidwhen'], 4, 2),
        substr($bidrec['bidwhen'], 0, 4),
        substr($bidrec['bidwhen'], 8, 2),
        substr($bidrec['bidwhen'], 10, 2)).":".substr($bidrec['bidwhen'], 12, 2);
        $bidrecords[]=$bidrec;
    }
      
    include (phpa_include("template_bidhistory_php.html"));
}


require("footer.php");
?>
